package mvc_generator.generator.car.struts

import mvc_generator.mVCGenerator.ModelMVC
import org.eclipse.xtext.generator.IFileSystemAccess

class WebGenerator {

	def void generate(ModelMVC model, IFileSystemAccess fsa) {

		var CharSequence webContent = '''''';

		webContent = '''''';

		webContent = '''
		<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>«model.name»</display-name>
  <welcome-file-list>
    <welcome-file>pages/«model.config.indexView.name»</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<!-- The below example tells the container that the servlet will be loaded
at first.
The <load-on-startup> sub-element indicates the order in which each servlet
should be loaded.
Lower positive values are loaded first. If the value is negative or
unspecified,
then the container can load the servlet at anytime during startup -->
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- declaring a JDBC data source -->
<resource-ref>
<description>JDBC resource to access my DB i.e.
dfj_hibernate</description>
<res-ref-name>jdbc/dsMyDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
		'''
		fsa.generateFile(model.name+"Struts"+StrutsGenerator.configPath + "web.xml", webContent);
	}

}
